package com.example.tsbs.binary;

public class WaveformSpectrumFormat {
    /**数据块数量*/
    private Integer nBulk;
    /**数据块0名称*/
    private String name;
    /**数据块0数据维度数*/
    private Integer nDim;
    /**数据块0数据类型*/
    private String[] dType;
    /**数据块0各数据维度名称*/
    private String dimNames;
    /**数据块0各数据维度长度*/
    private Integer length;
    /**数据块0数据*/
    private Float data;
    /**数据块1名称*/
    private String name2;
    /**数据块1数据维度数*/
    private Integer nDim2;
    /**数据块1数据类型*/
    private String[] dType2;
    /**数据块1各数据维度名称*/
    private String dimNames2;
    /**数据块1各数据维度长度*/
    private Integer length2;
    /**数据块1数据*/
    private Float data2;

    public WaveformSpectrumFormat(Integer nBulk, String name, Integer nDim, String[] dType, String dimNames, Integer length, Float data
            , String name2, Integer nDim2, String[] dType2, String dimNames2, Integer length2, Float data2) {
        setNBalk(nBulk);
        setName(name);
        setNDim(nDim);
        setDType(dType);
        setDimNames(dimNames);
        setLength(length);
        setData(data);
        setName2(name2);
        setNDim2(nDim2);
        setDType2(dType2);
        setDimNames2(dimNames2);
        setLength2(length2);
        setData2(data2);
    }

    // 合并字符串
    @Override
    public String toString() {
        return getNBalk() + getName() + getNDim() + getDType() + getDimNames() + getLength() + getData()
                + getName2() + getNDim2() + getDType2() + getDimNames2() + getLength2() + getData2();
    }

    public static void main(String[] args) {
        String[] dType = {"double","double"};
        String disNames = "time";
        Integer lengths = 3;
        WaveformSpectrumFormat bs = new WaveformSpectrumFormat(2, "wave",1,dType,disNames, lengths, 110f,
                "spectrum",1,dType, "frequency",lengths, 110f);
        System.out.println(bs);
        System.out.println("**************************");
    }
    public void setNBalk(Integer nBulk) {this.nBulk = nBulk;}
    public String getNBalk() {return String.format("%4d", nBulk);}

    public void setName(String name) {this.name = name;}
    public String getName() {return String.format("%16s", name);}

    public void setNDim(Integer nDim) {this.nDim = nDim;}
    public String getNDim() {return String.format("%4d", nDim);}

    public void setDType(String[] dType) {this.dType = dType;}
    public String getDType() {
        String res = "";
        for (String i : dType) {
            res += String.format("%8s", i);
        }
        res += String.format("%8s", "string");
        return res ;
    }

    public void setDimNames(String dimNames) {this.dimNames = dimNames;}
    public String getDimNames() {
        String res =  String.format("%16s", dimNames);
        return res ;
    }

    public void setLength(Integer length) {this.length = length;}
    public String getLength() {
        String res =  String.format("%4d", length);
        return res;
    }

    public void setData(float data) {this.data = data;}
    public String getData() {
        return String.format("%f", data) ;
    }

    public void setName2(String name) {this.name = name;}
    public String getName2() {return String.format("%16s", name);}

    public void setNDim2(Integer nDim) {this.nDim = nDim;}
    public String getNDim2() {return String.format("%4d", nDim);}

    public void setDType2(String[] dType) {this.dType = dType;}
    public String getDType2() {
        String res = "";
        for (String i : dType) {
            res += String.format("%8s", i);
        }
        res += String.format("%8s", "string");
        return res ;
    }

    public void setDimNames2(String dimNames) {this.dimNames = dimNames;}
    public String getDimNames2() {
        return String.format("%16s", dimNames);
    }

    public void setLength2(Integer length) {this.length = length;}
    public String getLength2() {
        return String.format("%4d", length);
    }

    public void setData2(float data) {this.data = data;}
    public String getData2() {
        return String.format("%f", data) ;
    }

}
